path_source=$(cd $(dirname $0)/..; pwd);
project_name=$(basename $path_source)

source $path_source/shell/def.sh

path_release=$path_source/release/$VERSION
file_path_min_mac=$path_release/mac/$SDK_NAME
file_path_mac=$file_path_min_mac'_source'

file_path_min_linux=$path_release/linux/$SDK_NAME
file_path_linux=$file_path_min_linux'_source'

file_path_min_win=$path_release/win/$SDK_NAME'.exe'
file_path_win=$path_release/win/$SDK_NAME'_source.exe'

rm -rf $path_release/*

mkdir -p $path_release

source .env

BUILD_TIME=`date +%Y%m%d.%H%M%S`
flags_main=" -X main.appname=${SDK_NAME} -X main.version=${VERSION} -X main.buildtime=${BUILD_TIME}"
flags="-s -w $flags_main "

# go build -ldflags "$flags" -o $file_path_mac
# upx -o $file_path_min_mac $file_path_mac

env GOOS=linux GOARCH=amd64 go build -ldflags "$flags" -o $file_path_linux
upx -o $file_path_min_linux $file_path_linux

# env GOOS=windows GOARCH=amd64 go build -ldflags "$flags" -o $file_path_win
# upx -o $file_path_min_win $file_path_win